package cn.rxls.community.controller;

import cn.rxls.community.dto.user.LoginDTO;
import cn.rxls.community.result.Result;
import cn.rxls.community.service.LoginService;
import cn.rxls.community.vo.login.LoginVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 登录、登出、注册
 */
@RestController
public class LoginController {

    @Resource
    private LoginService loginService;

    /**
     * 登录
     *
     * @param dto 参数对象
     * @return 用户登录信息
     */
    @PostMapping("/login")
    public Result<LoginVO> login(@Valid @RequestBody LoginDTO dto) {
        return Result.success(loginService.login(dto.getCode()));
    }

    /**
     * 退出登录
     */
    @GetMapping("/logout")
    public Result<?> logout(){
        return Result.success("退出登录");
    }

}
